package Visualisation;

import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JPanel;

public class DrawSimulation {
	private JPanel box;
	private Graphics g;
	private int Y = 115;
	private int lengthCar = 7;
	private int widthCar = 5;
	private final int MAX_ROAD_LENGTH=1600;

	public  DrawSimulation(JPanel b) { 
		box = b; 
	}
	
	public void drawPlot(int x){
		g = box.getGraphics();
		//Draw cars
				g.setColor(Color.BLACK);		//g.fillRect(x, Y, lengthCar, widthCar);
	}
	
	public void draw(int x){  
	
		g = box.getGraphics();
//Draw cars
		g.setColor(Color.BLUE);		g.fillRect(x, Y, lengthCar, widthCar);	
// Draw road
		g.setColor(Color.green);	g.fillRect(0,95,MAX_ROAD_LENGTH,12);
		g.setColor(Color.red);		g.drawLine(0,107,MAX_ROAD_LENGTH,107);
		
		g.setColor(Color.red);		g.drawLine(0,129,MAX_ROAD_LENGTH,129);
		g.setColor(Color.green);	g.fillRect(0,130,MAX_ROAD_LENGTH,12);
	}

	public void remove(int x){
		g = box.getGraphics();
		g.clearRect(x, Y, lengthCar, widthCar);
		
		//g.dispose();
	}
	public void color(int x){
		g.setColor(Color.red);		g.fillRect(x, Y, lengthCar, widthCar);	
	}
	
	public synchronized void plot(int x, int y){
		g.drawLine(x, y, x, y);
	}
}




